/**
 * Created by user on 2/13/19.
 */

const PREFIX = 'question_'
const QuestionActionType = {
  toggle_show: `${PREFIX}toggle_show`,
  init_question_list: `${PREFIX}init_question_list`,
  get_question_msg: `${PREFIX}get_question_msg`,
  get_question_up_msg: `${PREFIX}get_question_up_msg`,
  get_answer_msg: `${PREFIX}get_answer_msg`,
  get_answer_up_msg: `${PREFIX}get_answer_up_msg`,
  get_question_or_answer_msg: `${PREFIX}get_question_or_answer_msg`,
  do_self_like_item: `${PREFIX}do_self_like_item`,
  update_voice_status: `${PREFIX}update_voice_status`,
  stop_all_voice: `${PREFIX}stop_all_voice`,
  get_transfer_question_success_msg: `${PREFIX}get_transfer_question_success_msg`
}

function getTransferQuestionSuccessMsg({msg}) {
  return {
    type: QuestionActionType.get_transfer_question_success_msg,
    payload: {msg}
  }
}

function toggleShow(show) {
  return {
    type: QuestionActionType.toggle_show,
    payload: { show }
  }
}

function initQuestionList({ questions, answers }) {
  return {
    type: QuestionActionType.init_question_list,
    payload: { questions, answers }
  }
}

function getQuestionOrAnswerMsg({ msg, isRemoteSelf, isSelf, msgType }) {
  return {
    type: QuestionActionType.get_question_or_answer_msg,
    payload: { msg, isRemoteSelf, isSelf, msgType }
  }
}

function getQuestionMsg({ msg, isRemoteSelf, isSelf }) {
  return {
    type: QuestionActionType.get_question_msg,
    payload: { msg, isRemoteSelf, isSelf }
  }
}
function getQuestionUpMsg({ msg, isRemoteSelf, isSelf }) {
  return {
    type: QuestionActionType.get_question_up_msg,
    payload: { msg, isRemoteSelf, isSelf }
  }
}
function getAnswerMsg({ msg, isRemoteSelf, isSelf }) {
  return {
    type: QuestionActionType.get_answer_msg,
    payload: { msg, isRemoteSelf, isSelf }
  }
}
function getAnswerUpMsg({ msg, isRemoteSelf, isSelf }) {
  return {
    type: QuestionActionType.get_answer_up_msg,
    payload: { msg, isRemoteSelf, isSelf }
  }
}

function doSelfLikeItem({ msgType, id }) {
  return {
    type: QuestionActionType.do_self_like_item,
    payload: { msgType, id }
  }
}

function updateVoiceStatus(payload) {
  return {
    type: QuestionActionType.update_voice_status,
    payload
  }
}
function stopAllVoice() {
  return {
    type: QuestionActionType.stop_all_voice
  }
}

module.exports = {
  QuestionActionType,
  toggleShow,
  initQuestionList,
  getQuestionMsg,
  getQuestionUpMsg,
  getAnswerMsg,
  getAnswerUpMsg,
  getQuestionOrAnswerMsg,
  doSelfLikeItem,
  updateVoiceStatus,
  stopAllVoice,
  getTransferQuestionSuccessMsg
}
